package com.workerhelping.controller;

import com.workerhelping.dto.AssistInfoDTO;
import com.workerhelping.result.Result;
import com.workerhelping.service.AssistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/assist")
public class AssistController {

    @Autowired
    private AssistService assistService;

    /**
     * 向MySQL插入帮扶信息
     * @param assistInfoDTO
     * @return
     */
    @PostMapping("/insertAssistInfo")
    public Result<String> insertAssistInfo(@RequestBody AssistInfoDTO assistInfoDTO) {
        try {
            boolean isSave = assistService.saveBatch(assistInfoDTO.getAssistInfos());
            if (!isSave)
                return Result.fail();
            return Result.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return Result.fail();
        }
    }
}
